program main
    use DQ
    implicit none
    integer(4), parameter :: iwp=8, n = 8, maxorder = 3
    real(8), parameter :: pi = 3.1415926535897932d0
    integer(4) :: i, j, k, L
    real(iwp) :: xlist(n), c(0:maxorder, n, n), a = 0d0, b = 2d0 * pi

    call expandedCheb(n, xlist)
    xlist = 0.5d0 * (b-a) * xlist + (b+a) * 0.5d0

    !测试全局微分求积法权系数的计算
    call DQCoeff(xlist, maxorder, c)
    open(unit = 10, file = "Global_DQ_Coeffs.txt")
    do k=0,maxorder
        write(10,"(/a8, i2)") "order= ", k
        write(10, "(8(e24.16))" ) ((c(k,i,j),j=1,n),i=1,n)
    end do
    close(10)
    
    !测试局部微分求积法权系数的计算
    open(unit = 10, file = "Local_DQ_Coeffs.txt")
    do L=3, 8
        write(10,"(//a8, i2)") "bandWidth= ", L
        call LocalDQCoefficients(xlist, L, maxorder, c)
        do k=0,maxorder
            write(10,"(/a8, i2)") "order= ", k
            write(10, "(8(e24.16))") ((c(k,i,j),j=1,n),i=1,n)
        end do
    enddo
    close(10)
end program main